<?
session_start();
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<?

$teacher_username = $_POST['usernm'];
$teacher_id = $_POST['passwd'];


$sql=" select teacher_id,teacher_username,type_user
         from vlogin
		 where teacher_username='$teacher_username' and teacher_id='$teacher_id' ";
$result=mysql_query($sql)or die(mysql_error());
$numrows=mysql_num_rows($result);


if($numrows==0){
	  echo "<script>alert('ชื่อผู้ใช้หรือรหัสผ่านไม่ถูกต้อง กรุณาเข้าใหม่ค่ะ');</script>";
	  echo $func->redirect("0","index.php");
}
else{
    $fetch=mysql_fetch_array($result);

    $_SESSION['sess_userid']=$fetch['teacher_id'];
    $_SESSION['sess_name']=$fetch['teacher_username'];
	$_SESSION['sess_type']=$fetch['type_user'];
    
	echo $func->alert("ยินดีต้อนรับคุณ $fetch[teacher_username] สถานะคือ $fetch[type_user]");
	echo $func->redirect("0","index.php");
}


?>
